const {BrowserWindow} = require('electron')

module.exports=[
  {
    name:'setPosition',
    type:'on',
    func(event,dx,dy){
      const win = BrowserWindow.fromWebContents(event.sender)
      const [x,y]=win.getPosition()
      win.setPosition(x+dx,y+dy)
    }
  },
  {
    name:'setWindowState',
    type:'on',
    func(event,str){
      const win = BrowserWindow.fromWebContents(event.sender)
      switch (str){
        case 'min':
          win.minimize()
          break
        case 'max':
          if (win.isMaximized()){
            win.unmaximize()
          }else{
            win.maximize()
          }
          break
        case 'close':
          win.close()
          break
      }
    }
  }
]
  
